package com.wang.controller;

import com.wang.exception.CustomException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin
public class HelloController {
    @ResponseBody
    @GetMapping("/show")

    public String showMsg() {
        return "success";
    }

    @ResponseBody
    @RequestMapping("/show2")
    public String showMsg2() {
        return "success";
    }

    @GetMapping("/showError")
    public void showError() {
        throw new RuntimeException("自定义异常...");
    }

    @RequestMapping("/json")
    public String handleJsonException() throws CustomException {
        throw new CustomException("json格式的异常处理方案...");
    }
}